package com.hellobike.haxing.modules.shop.job;

import com.hellobike.haxing.common.constant.CacheConstant;
import com.hellobike.haxing.common.util.RedisUtil;
import com.hellobike.haxing.modules.shop.service.IShopWithdrewMonthCountService;
import com.hellobike.haxing.modules.shop.service.IShopWithdrewService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时查询打款中的结果
 */
@Slf4j
@Component
public class WithdrewLoanStatusJob {

    @Autowired
    private IShopWithdrewService shopWithdrewService;

    @Autowired
    private RedisUtil redisUtil;

    @Scheduled(fixedDelay = 10 * 60 * 1000)
    public void execute() {
        Object result = redisUtil.get(CacheConstant.QUERY_WITHDREW_RESULT_JOB);
        if (result != null) {
            return;
        }
        redisUtil.set(CacheConstant.QUERY_WITHDREW_RESULT_JOB, 1, 500);
        shopWithdrewService.updateSettleQuery();
    }
}
